package com.fit.components;

import org.apache.tapestry5.*;
import org.apache.tapestry5.annotations.*;
import org.apache.tapestry5.ioc.annotations.*;
import org.apache.tapestry5.BindingConstants;

import com.fit.entities.User;

/**
 * Layout component for pages of application mtel.
 */
@Import(stylesheet = {"context:layout/layout.css"})
public class Layout
{
    /** The page title, for the <title> element and the <h1> element. */
  	@Property
    @Parameter(required = false, defaultPrefix = BindingConstants.LITERAL)
    private String title;

    @Property
    private String pageName;

    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private String sidebarTitle;

    @Property
    @Parameter(defaultPrefix = BindingConstants.LITERAL)
    private Block sidebar;

    @Inject
    private ComponentResources resources;
    
    @Property
    @SessionState
    private User user;
    
	private boolean userExists;

    public String getClassForPageName()
    {
      return resources.getPageName().equalsIgnoreCase(pageName)
             ? "current_page_item"
             : null;
    }

    public String[] getPageNames()
    {
      return new String[] { "Index" };
    }
    
    public boolean isUserLogedIn() {
    	if(userExists) {
    		return true;
    	}else {
    		return false;
    	}
    }
}
